﻿using System;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using Runda.EShop.Common.Utility;

namespace Runda.EShop.Dal
{
    /// <summary>
    /// DAL layer class dbo.Bas_Product_Relation.
    /// </summary>
    public partial class BasProductRelationDal 
    {
        public DataTable GetRelationProduct(Guid ProductID)
        {
            string sql = @"select B.*,case when C.ProductID IS NULL then 0 ELSE 1 END as IsCart 
from  Bas_Product_Relation A JOIN Bas_Product B
ON A.RelationID = B.ProductID
LEFT JOIN Biz_ShopCart C ON A.RelationID=C.ProductID WHERE A.ProductID=@ProductID";

            DbCommand dbcommand = CurrentDatabase.GetSqlStringCommand(sql);
            CurrentDatabase.AddInParameter(dbcommand, "@ProductID", DbType.Guid, ProductID);
            return CurrentDatabase.ExecuteDataSet(dbcommand).Tables[0];
        }
    }
}
